/**
 * Created by losor on 2017/3/5.
 */
public class _485_MaxConsecutiveOnes
{
    public static void main(String[] args) {

    }

    public int findMaxConsecutiveOnesBigBoss(int[] nums) {
        int maxHere = 0, max = 0;
        for (int n : nums)
        //利用了Math的max就省去了写判断
            max = Math.max(max, maxHere = n == 0 ? 0 : maxHere + 1);
        return max;
    }

    public int findMaxConsecutiveOnes(int[] nums) {
        int count = 0;
        int maxCount = 0;
        for (int n:nums
             ) {
            if (n == 0){
                if (count > maxCount) {
                    maxCount = count;
                }
                count = 0;
            }
            else{
                count ++;
            }
        }
        if (count > maxCount) {
            maxCount = count;
        }
        return maxCount;
    }
}
